﻿/*
 * Created by SharpDevelop.
 * User: rogerio
 * Date: 30/12/2009
 * Time: 8:57
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;

namespace csharp.rad.finan
{
	/// <summary>
	/// Description of Cfop.
	/// </summary>
	public class Cfop : csharp.common.DefaultClass, csharp.common.IClass
	{
		#region Declaration Variables
		private String _comentaty;
  		private String _description;
  		private String _grupo_cfop_id;
  		private String _subgrupo_cfop_id;
  		private String _aditional_data;
  		#endregion
  		
		public Cfop()
		{
			clear();
			
			gsql.table = "finan.cfop";
			_sequence  = "finan.cfop_cfop_id_seq";
		}
		
		#region Declaration methods Gets end Sets
		public string Comentaty {
			get { return _comentaty; }
			set { _comentaty = value; }
		}
		
		public string Description {
			get { return _description; }
			set { _description = value; }
		}
		
		public string Grupo_cfop_id {
			get { return _grupo_cfop_id; }
			set { _grupo_cfop_id = value; }
		}
		
		public string Subgrupo_cfop_id {
			get { return _subgrupo_cfop_id; }
			set { _subgrupo_cfop_id = value; }
		}
		
		public string Aditional_data {
			get { return _aditional_data; }
			set { _aditional_data = value; }
		}
		
		#endregion
		
		public void clear()
		{
			_id  				= String.Empty;
			_comentaty			= String.Empty;
  		    _description		= String.Empty;
  		    _grupo_cfop_id		= String.Empty;
  		    _subgrupo_cfop_id	= String.Empty;
  		    _aditional_data	    = String.Empty;
		}
		
		public override bool delete()
		{
			return base.delete();
		}
		
		public override void get(System.Data.DataRow dr)
		{
			_id  				= dr["cfop_id"].ToString();
			_comentaty			= dr["cfop_comentaty"].ToString();
			_description		= dr["cfop_description"].ToString();
			_grupo_cfop_id		= dr["cfop_grupo_cfop_id"].ToString();
			_subgrupo_cfop_id	= dr["cfop_subgrupo_cfop_id"].ToString();
			_aditional_data	    = dr["cfop_aditional_data"].ToString();
		}
		
		public override bool save()
		{
			return base.save();
		}
		
		public override void setGsql()
		{
			gsql.setValue(_id  				    ,"cfop_id");
			gsql.setValue(_comentaty			,"cfop_comentaty");
			gsql.setValue(_description		    ,"cfop_description");
			gsql.setValue(_grupo_cfop_id		,"cfop_grupo_cfop_id");
			gsql.setValue(_subgrupo_cfop_id	    ,"cfop_subgrupo_cfop_id");
			gsql.setValue(_aditional_data	    ,"cfop_aditional_data");
		}
		
		public override bool store(csharp.common.GenerateSql.TCommandType ctype)
		{
			return base.store(ctype);
		}
		
		public override bool update()
		{
			return base.update();
		}
		
	}
	
	public class Cfops : csharp.common.DefaultList, csharp.common.IList
	{
		public Cfops()
		{
			gsql.table = "finan.cfop";
		}
		
		public Cfop get(Int32 index)
		{
			return (Cfop)items[index];
		}
		
		public Cfop get()
		{
			return (Cfop)items[index];
		}
				
		public bool fillList()
		{
			gsql.prepare();
			gsql.setValue("","*");
			gsql.additionalWhere = "ORDER BY cfop_description";
			
			return mountList();
		}
		
		private bool mountList()
		{
			Int32 tam;
			
			if (!gsql.execute())
				return false;
			
			items.Clear();
			tam= gsql.getRowCount();
			for (int i=0; i < tam; i++)
			{
				Cfop c = new Cfop();
				c.get(gsql.getRow(i));
				items.Add(c);
			}
			return true;
		}		
	}
}
